//
//  YQHeadView.m
//  NewRetail
//
//  Created by yuqin on 2019/6/24.
//  Copyright © 2019 yuqin. All rights reserved.
//

#import "YQHeadView.h"
@interface YQHeadView ()

@property (nonatomic, strong) UILabel *theTitleLab;
@property (nonatomic, strong) UIView *lineView;

@end

@implementation YQHeadView

- (void)setupContentView {
    [self addSubview:self.bigImgView];
    [self addSubview:self.theTitleLab];
    [self addSubview:self.lineView];
    
    
    [self.bigImgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(0);
        make.top.mas_equalTo(FIT(0));
        make.size.mas_equalTo(CGSizeMake(ScreenWidth, FIT(200)));
    }];
    
    [self.theTitleLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(kMargin_left);
        make.top.equalTo(self.bigImgView.mas_bottom).mas_equalTo(FIT(20));
        make.size.mas_equalTo(CGSizeMake(FIT(100), FIT(21)));
    }];
    
    [self.lineView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.mas_equalTo(0);
        make.top.equalTo(self.theTitleLab.mas_bottom).mas_equalTo(FIT(20));
        make.size.mas_equalTo(CGSizeMake(ScreenWidth, 1));
    }];
    
    NSDictionary *titleDict = @{@"1":@"WDC",
                                @"2":@"WDC",
                                @"3":@"WDC",
                                @"4":@"WDC"
                                };
    CGFloat btn_w = ScreenWidth/4.0;
    for (NSInteger i = 0; i < 4; i++) {
        UIButton *btn = [YQViewFactory buttonWithTitle:[titleDict objectForKey:StringFromLongInt(i+1)] image:YQ_IMAGE(@"") titleColor:MainBlackColor fontSize:kNormalButtonFont userBold:NO target:self sel:@selector(chooseAction:)];
        btn.tag = 100+i;
        [self addSubview:btn];
        [btn mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.mas_equalTo(btn_w*i);
            make.top.equalTo(self.lineView.mas_bottom).mas_equalTo(0);
            make.size.mas_equalTo(CGSizeMake(btn_w, FIT(80)));
        }];
    }
    
}

- (void)chooseAction:(UIButton *)sender {
    if (self.block) {
        self.block(sender.tag);
    }
}

- (UIImageView *)bigImgView {
    if (!_bigImgView) {
        _bigImgView = [YQViewFactory imageViewWithImage:YQ_IMAGE(@"found_head")];
//        _bigImgView.backgroundColor = MainBlueColor;
//        _bigImgView.layer.cornerRadius = 5.f;
//        _bigImgView.layer.masksToBounds = YES;
    }
    return _bigImgView;
}

- (UILabel *)theTitleLab {
    if (!_theTitleLab) {
        _theTitleLab = [YQViewFactory labelWithTextColor:MainBlackColor textAlignment:NSTextAlignmentLeft fontSize:kTheTitleFont userBold:NO];
        _theTitleLab.text = @"应用";
    }
    return _theTitleLab;
}

- (UIView *)lineView {
    if (!_lineView) {
        _lineView = [[UIView alloc] init];
        _lineView.backgroundColor = LineColor;
    }
    return _lineView;
}

@end
